<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<include file="Public:base" />

<script type="text/javascript">
$(document).ready(function() {
	
	//代理方法 也能 绑定 未生成的 元素 
	$(".statusspan").on('click',"a", function () {
		   var idval = $(this).attr("id");
		   var id = idval.split("_")[1];
	     	$.post("__URL__/lock/id/"+id, function (result) {
	     		if(result=="lock"){
	     			bootbox.alert("已锁定", function() {
	                  $("#lock_"+id).parent().html('锁定 |<a id="lock_'+id+'">开启</a>');
	              });
	     		}else if(result=="unlock"){
	     			bootbox.alert("已开启", function() {
		                  $("#lock_"+id).parent().html('开启 |<a id="lock_'+id+'">锁定</a>');
		              });
	     		}else {
	     			bootbox.alert("处理失败", function() {
	                  //console.log("Alert Callback");
	              });
	     		}
	     		
		    }); 
	});
	
	
	$("[id^=delart]").on("click", function () {
		 var idval = $(this).attr("id");
		 bootbox.confirm("确认删除", function(result) {
          if(result){
       	   var id = idval.split("_")[1];
       	 	$.post("__URL__/del/id/"+id, function (result) {
	       		if(result=="del"){
                    $("#comm-item_"+id).hide();
	       		}else {
	       			bootbox.alert("删除失败", function() {
                        //console.log("Alert Callback");
                 });
	       		}
	       		
		    }); 	
   	       	
          }
        });
   });
	
});
</script>
</head>
<body>
<include file="Public:header" />

<div class="home-index">
  <div class="container">
    <div class="row">
       <ol class="breadcrumb">
        <li>首页</li>
        <li>新闻管理</li>
        <li class="active">新闻列表</li>
      </ol>
      <div class="search-box">
        <form class="form-inline" role="form" action="__URL__/index" method="get">
          <div class="form-group">
            <label class="sr-only" >关键词</label>
            <input type="text" class="form-control input-large" name="title" value="{$title}" placeholder="搜索其实很简单...">
          </div>
           <div class="form-group ">
		        <label class="sr-only" >分类</label>
		        <html:select id='category_id' name='category_id' style="form-control" options='catelist' first='分类' />
		   </div>
		   
          <button type="submit" class="btn btn-primary">搜索</button>
          <a href='__URL__/add' class="btn btn-primary">添加新闻</a>
          
        </form>
      </div>
	
      <table class="table table-striped">
        <thead>
          <tr>
            <th>#</th>
            <th>标题</th>
			<th>分类</th>
            <th>点击数</th>
            <th>状态</th>
            <th>创建时间</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody>
         
          <volist name='data' id='vo'>
          <tr id="comm-item_{$vo.id}">
            <td>{$vo.id}</td>
            <td>
        
            	<a href="">{$vo.title}</a>
            </td>
            <td><a href="__URL__/index/category_id/{$vo.category_id}">[{$vo.catename}]</a></td>
            <td>{$vo.hits}</td>
            <td>
            	<span class='statusspan'>
            	<if condition=" $vo.status ">
		 		锁定 | <a id="lock_{$vo.id}" >开启</a>
		 		<else />
				 开启 | <a id="lock_{$vo.id}" >锁定</a>
				 </if>
            	</span>
			</td>
            <td>{$vo.created_at|date="Y-m-d",###}</td>
            <td class="opts">
            
              <a href="__URL__/modify/id/{$vo.id}" title="编辑" class="icon-edit"></a> | 
              <a id="delart_{$vo.id}" href="javascript:;" title="删除" class="icon-trash"></a> |
            	
            	<!-- 
            	<if condition=" ($vo.flag neq '') and ($vo.flag neq 'normal')">
            		<a href="__MODULE__/Photos/getlist/id/{$vo.id}" title="实景照" class="icon-picture"></a> 
            	<else />
            	</if>
            	  -->
            </td>
          </tr>
          </volist> 
        </tbody>
      </table>
    </div>
    {$page}
  </div>
</div>

</body>
</html>